package com.sun.showcase.controller.mall;

import com.sun.showcase.biz.mall.service.SkuAttributeValueService;
import com.sun.showcase.client.domain.mall.SkuAttributeValue;
import com.sun.showcase.client.query.mall.SkuAttributeValueQuery;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value="/mall/skuAttributeValue")
public class SkuAttributeValueController{
	
	@Autowired
	private SkuAttributeValueService skuAttributeValueService;
	
	private Result result = new Result();
	/**
	 * 跳转到SkuAttributeValue管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goSkuAttributeValue")
	public String goSkuAttributeValue() {
		return "mall/skuAttributeValue";
	}
	/**
	 * 跳转到SkuAttributeValue新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleSkuAttributeValue")
	public String handleSkuAttributeValue(@RequestParam(value="id",required=false) Long id , ModelMap map) {
		return "mall/skuAttributeValue_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public SkuAttributeValue showDesc(SkuAttributeValueQuery skuAttributeValueQuery) {
		return skuAttributeValueService.get(skuAttributeValueQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(SkuAttributeValueQuery skuAttributeValueQuery) {
		return skuAttributeValueService.datagrid(skuAttributeValueQuery);
	}
	

	/**
	 * 添加一个SkuAttributeValue
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Result add(SkuAttributeValueQuery skuAttributeValueQuery) {
		skuAttributeValueService.add(skuAttributeValueQuery);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑SkuAttributeValue
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Result edit(SkuAttributeValueQuery skuAttributeValueQuery) {
		skuAttributeValueService.update(skuAttributeValueQuery);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除SkuAttributeValue
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Result delete(SkuAttributeValueQuery skuAttributeValueQuery) {
		skuAttributeValueService.delete(skuAttributeValueQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除SkuAttributeValue
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Result deletePt(SkuAttributeValueQuery skuAttributeValueQuery) {
		skuAttributeValueService.deletePt(skuAttributeValueQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	/**
	 * 全部数据SkuAttributeValue
	 */
	@ResponseBody
	@RequestMapping(value="listAll")
	public Result listAll(SkuAttributeValueQuery skuAttributeValueQuery) {
		List<SkuAttributeValueQuery> list = skuAttributeValueService.listAll(skuAttributeValueQuery);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(list);
		return result;
	}
}
